layui.define(function (exports) {
	//接收错误
	// window.onerror = function(){
	//     console.error(arguments);
	// 	return true;
 //    };
	var obj = {
		date: function(value, options){
			if(value != false && is_int(value)){
				value = formatDate(value * 1000, 'Y-M-D');
			}
			return value;
		},
		hidden: function(value, options){
			return value;
		},
		text: function(value, options){
			// if(is_object(value)){
			// 	value = json_encode(value);
			// }
			return value;
		},
		image: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					return '<img onclick="pictureBrowser(this)" style="max-height: 40px;" src="'+evalue.url+'" title="'+evalue.original+'">';
				}catch(e){
					return value;
				}				
			}
			return '';
		},
		images: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					var html = '';
					for(imgi in evalue){
						var image = eval('('+evalue[imgi]+')');
						html += '<img onclick="pictureBrowser(this)" style="max-height: 40px;" src="'+image.url+'" title="'+image.original+'" >';
					}
					return html;
				}catch(e){
					return value;
				}
			}
			return '';
		},
		select: function(value, options){
			if(options[value] != undefined){
				
				value =  options[value];
				var length = substr_count(value, '|——');
				for(svi = 0;  svi < length ; svi ++){
					value = value.replace("|——", "");
					value = value.replace("&nbsp;&nbsp;", "");
					value = value.replace("&nbsp;&nbsp;", "");
				}
			}
			return value;
		},
		number: function(value, options){
			return value;
		},
		password: function(value, options){
			return value;
		},
		radio: function(value, options){
			if(options[value] != undefined){
				return options[value];
			}
			return value;
		},
		checkbox: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					var str = '';
					for(ci in evalue){
						if(options[evalue[ci]] != undefined){
							str += options[evalue[ci]]+ ' ';
						}else{
							str += evalue[ci]+ ' ';
						}
					}
					return str;
				}catch(e){
					return value;
				}
			}
			return '';
		},
		float: function(value, options){
			return value;
		},
		color: function(value, options){
			return value;
		},
		file: function(value, options){
			return value;
		},
		textarea: function(value, options){
			return value;
		},
		video: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					if(evalue.thumbnail == false){
						evalue.thumbnail = '/admin/static/img/no-exist.jpg';
					}
					return '<img onclick="videoBrowser(this)" style="max-height: 40px;" src="'+evalue.thumbnail+'" data-url="'+evalue.url+'"   title="'+evalue.original+'">';
				}catch(e){
					return value;
				}
				
			}
			return '';
		},
		videos: function(value, options){
			if(value){
				var evalue = eval('('+value+')');
				var html = '';
				for(imgi in evalue){
					var image = eval('('+evalue[imgi]+')');
					if(image.thumbnail == false){
						image.thumbnail = '/admin/static/img/no-exist.jpg';
					}
					html += '<img onclick="videoBrowser(this)" style="max-height: 40px;" src="'+image.thumbnail+'" data-url="'+image.url+'"  title="'+image.original+'">';
				}
				return html;
			}
			return '';
		},
		audio: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					return '<a onclick="audioBrowser(this)" style="max-height: 40px;" data-url="'+evalue.url+'" title="'+evalue.original+'">'+evalue.original+'</a>';
				}catch(e){
					return value;
				}
				
			}
			return '';
		},
		audios: function(value, options){
			// non-existent 
			if(value){
				try{
					var evalue = eval('('+value+')');
					var html = '';
					for(imgi in evalue){
						var image = eval('('+evalue[imgi]+')');
						if(image.thumbnail == false){
							image.thumbnail = '/admin/static/img/no-exist.jpg';
						}
						html += '<a onclick="audioBrowser(this)" style="max-height: 40px;" data-url="'+image.url+'" title="'+image.original+'">音频&nbsp;</a>';
					}
					return html;
				}catch(e){
					return value;
				}
			}
			return '';
		},
		document: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					return evalue.original;
				}catch(e){
					return value;
				}
			}
			return '';
		},
		documents: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					var html = '';
					for(imgi in evalue){
						var image = eval('('+evalue[imgi]+')');
						html += image.original+',';
					}
					return html;
				}catch(e){
					return value;
				}
			}
			return '';
		},
		time: function(value, options){
			if(value != false && is_int(value)){
				value = formatDate(value * 1000, 'Y-M-D H:i:s');
			}
			return value;
		},
		checkboxwindow: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					var html = '';
					for(imgi in evalue){
						var image = eval('('+evalue[imgi]+')');
						html += image.title+',';
					}
					return html;
				}catch(e){
					return value;
				}
			}
			return '';
		},
		radiowindow: function(value, options){
			if(value){
				try{
					var evalue = eval('('+value+')');
					return evalue.title;
				}catch(e){
					return value;
				}
			}
			return '';
		},
		baidueditor: function(value, options){
			return value;
		},
		url: function(value, options){
			return value;
		}
	};
	exports('parsedata', obj);//导出
});